package com.regex.web.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import com.alibaba.fastjson.JSON;

/**
 * 数据传输类
 * @author ocean
 *
 * @param <T>
 */
public class TransData<T> {


	/********* 操作 o ************/
	public static int ADD = 1;
	public static int UPDATE = 2;
	public static int DELETE = 3;
	public static int SELECT = 4;

	public static Map<Integer, String> controls = new HashMap<Integer, String>();
	static {
		controls.put(ADD, "新增");
		controls.put(UPDATE, "修改");
		controls.put(DELETE, "删除");
		controls.put(SELECT, "查询");
	}

	/********* 返回状态 g ************/
	public static int SUCCESS = 1;
	public static int ERROR = 2;
	public static int PARAMS_ERROR = 3;
	public static int EMPTY_RECORD = 4;
	public static int ERROR_VERIFYCODE = 5;
	public static int CODE_ERROR = 6;
	public static int USE_OVER = 7;
	public static int ROLE_OVERDUE = 8;
	public static int NOT_OWN = 9;
	public static int OLD_PASSWORD_ERROR = 10;
	public static int DATA_REPEAT = 11;
	public static int PASSWORD_ERROR = 12;
	public static int USER_IS_EMPTY = 13;
	public static int USER_ALREADY_REGIST = 14;
	public static int CONFIRM_PASS_ERROR = 15;
	public static int CODE_SEND_FREE = 16;
	public static int CODE_OVERDUE = 17;
	public static int MESSAGE_SCENE = 18;
	public static int TOKEN_EMPTY = 19;
	public static int TOKEN_OVERTIME = 20;
	public static int PROPRIETOR_IS_NULL = 21;
	public static int PROPRIETOR_IS_AUTHED = 22;
	public static int PROPRIETOR_IS_NULL_AUTHED = 23;
	public static int YOUR_PROPRIETOR_IS_AUTHED = 24;
	public static int DATA_IS_NULL = 25;
	public static int PASSWORD_CONFIRM_ERROR = 26;
	public static int PAY_IS_FINISH = 27;
	public static int APP_NO_AUTHORITY = 401;
	public static int SYSTEM_ERROR = 403;
	public static int IIIEGA_LAWLESS = 500;

	public static Map<Integer, String> errors = new HashMap<Integer, String>();
	static {
		errors.put(SUCCESS, "成功");
		errors.put(ERROR, "失败");
		errors.put(PARAMS_ERROR, "参数为空");
		errors.put(EMPTY_RECORD, "空记录");
		errors.put(ERROR_VERIFYCODE, "非法登录");
		errors.put(CODE_ERROR, "验证码错误");
		errors.put(USE_OVER, "次数已用完");
		errors.put(ROLE_OVERDUE, "过期");
		errors.put(NOT_OWN, "未拥有");
		errors.put(OLD_PASSWORD_ERROR, "原密码错误");
		errors.put(PASSWORD_ERROR, "密码错误");
		errors.put(DATA_REPEAT, "数据重复");
		errors.put(USER_IS_EMPTY, "用户未注册");
		errors.put(USER_ALREADY_REGIST, "手机号已注册");
		errors.put(CONFIRM_PASS_ERROR, "确认密码错误");
		errors.put(CODE_SEND_FREE, "1分钟内只能发送一次验证码");
		errors.put(CODE_OVERDUE, "验证码已过期");
		errors.put(MESSAGE_SCENE, "短信验证码场景不能为空");
		errors.put(TOKEN_EMPTY,"token不能为空");
		errors.put(TOKEN_OVERTIME, "token已超时");
		errors.put(PROPRIETOR_IS_NULL, "房屋业主不存在");
		errors.put(PROPRIETOR_IS_AUTHED, "业主已认证");
		errors.put(PROPRIETOR_IS_NULL_AUTHED, "业主未认证");
		errors.put(YOUR_PROPRIETOR_IS_AUTHED, "您已申请该业主认证");
		errors.put(DATA_IS_NULL, "数据不存在");
		errors.put(PASSWORD_CONFIRM_ERROR, "确认密码不正确");
		errors.put(PAY_IS_FINISH, "该记录已缴费完成"); 
		errors.put(APP_NO_AUTHORITY, "没有权限");
		errors.put(SYSTEM_ERROR, "系统错误");
		errors.put(IIIEGA_LAWLESS, "非法登录");
	}

	/********* 终端 t ************/
	public static int APP_ANDROID = 1;
	public static int APP_IOS = 2;
	public static int APP_PC = 3;

	public static Map<Integer, String> terminal = new HashMap<Integer, String>();
	static {
		terminal.put(APP_ANDROID, "ANDROID_APP");
		terminal.put(APP_IOS, "IOS_APP");
		terminal.put(APP_PC, "PC");
	}

	public static String DEBUG = "debug";
	
	public static String FIELD = "field";

	public static String TOKEN = "token";

	public static String TOKEN_TEL = "tel";

	/**
	 * 操作
	 */
	private int o;
	/**
	 * 返回状态
	 */
	private int g;
	/**
	 * 终端
	 */
	private int t;
//	/**
//	 * 业务系统
//	 */
//	private int s;
	/**
	 * 接口标识
	 */
	private int p;

	/**
	 * 提示信息
	 */
	private String a;
	
	/**
	 * 版本信息
	 */
	private String v;
	
	/**
	 * 访问地址
	 */
	private String r;
	
	/**
	 * 分页参数 从request分离出来分页参数
	 */
	private Map<String, Object> u = new TreeMap<String, Object>();
	/**
	 * 排序参数 从request分离出来分页参数
	 */
	private Map<String, Object> h = new TreeMap<String, Object>();
	/**
	 * request 存放 查询条件 删除条件 修改条件 response 存放 分页明细 单数据等
	 */
	private Map<String, Object> m = new TreeMap<String, Object>();
	/**
	 * request 存放 添加记录 修改记录 response 存放 分页结果 集合结果 等
	 */
	private T data;

	public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getO() {
		return o;
	}

	public void setO(int o) {
		this.o = o;
	}

	public int getG() {
		return g;
	}

	public void setG(int g) {
		this.g = g;
	}

	public int getT() {
		return t;
	}

	public void setT(int t) {
		this.t = t;
	}

//	public int getS() {
//		return s;
//	}
//
//	public void setS(int s) {
//		this.s = s;
//	}

	public int getP() {
		return p;
	}

	public void setP(int p) {
		this.p = p;
	}

	public Map<String, Object> getM() {
		return m;
	}

	public void setM(Map<String, Object> m) {
		this.m = m;
	}


	public String getA() {
		return a;
	}

	public void setA(String a) {
		this.a = a;
	}

	public Map<String, Object> getU() {
		return u;
	}

	public void setU(Map<String, Object> u) {
		this.u = u;
	}

	public Map<String, Object> getH() {
		return h;
	}

	public void setH(Map<String, Object> h) {
		this.h = h;
	}

	public String getV() {
		return v;
	}

	public void setV(String v) {
		this.v = v;
	}

	public String getR() {
		return r;
	}

	public void setR(String r) {
		this.r = r;
	}

	@Override
	public String toString() {
		return "TransData [o=" + o + ", g=" + g + ", t=" + t + ", p=" + p + ", a=" + a
				+ ", v=" + v + ", r=" + r + ", u=" + u + ", h=" + h + ", m=" + m + ", data=" + JSON.toJSONString(data) + "]";
	}
}
